package domain.scenes;

import sounds.Sounds;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.GameComponent;
import com.uqbar.vainilla.GameScene;
import com.uqbar.vainilla.appearances.Sprite;
import com.uqbar.vainilla.events.constants.Key;
import components.ClickeableComponent;
import components.Cursor;

public class GameOptionsScene extends GameScene {

	//alineamiento
	private int titleXalign;
	private int titleYalign;
	
	private int gameModesXalign;
	private int gameModesYalign;
	private int mapsXalign;
	private int mapsYalign;
	
	//opciones elegidas
	private int numberOfWorms;
	private int numberOfTeams;
	private int map;
	
	//opciones components
	private ClickeableComponent mode1v1;
	private ClickeableComponent mode2v2;
	
	public GameOptionsScene(){
		
		(Sounds.sounds.get("presentation")).play();
		
		this.setNumberOfWorms(1);
		this.map = 1;
		this.numberOfTeams = 2;
		
		//
		this.titleXalign = 100;
		this.titleYalign = 50;
		this.mapsXalign = 600;
		this.mapsYalign = 200;
		this.gameModesXalign = 100;
		this.gameModesYalign = 200;
		//
		this.addBackground();
		this.addLabels();
		this.addChoices();

		this.addCursor();
	}

	private void addCursor() {
		Sprite sp1 = Sprite.fromImage("/images/presentation/cursor.PNG");
		sp1 = sp1.scaleTo(25, 25);
		Cursor cursor = new Cursor(sp1);
		
		this.addComponent(cursor);
	}

	private void addChoices() {
		
		Sprite s1v1 = Sprite.fromImage("/images/presentation/1v1.PNG");
		mode1v1 = new ClickeableComponent(gameModesXalign, gameModesYalign, s1v1, 100, 50){
			public void onLeftClick(){
				numberOfWorms = 1;
				numberOfTeams = 2;
			}
		};
		
		Sprite s2v2 = Sprite.fromImage("/images/presentation/2v2.PNG");
		mode2v2 = new ClickeableComponent(gameModesXalign, gameModesYalign+ 100, s2v2, 100, 50){
			public void onLeftClick(){
				numberOfWorms = 2;
				numberOfTeams = 2;
			}
		};
		ClickeableComponent mode3v3;
		Sprite s3v3 = Sprite.fromImage("/images/presentation/3vs3.PNG");
		mode3v3 = new ClickeableComponent(gameModesXalign, gameModesYalign+ 200, s3v3, 100, 50){
			public void onLeftClick(){
				numberOfWorms = 3;
				numberOfTeams = 2;
			}
		};
		
		ClickeableComponent mode1v1v1;
		Sprite s1v1v1 = Sprite.fromImage("/images/presentation/1v1v1.PNG");
		mode1v1v1 = new ClickeableComponent(gameModesXalign, gameModesYalign+ 300, s1v1v1, 120, 50){
			public void onLeftClick(){
				numberOfWorms = 1;
				numberOfTeams = 3;
			}
		};
		
		Sprite sp3 = Sprite.fromImage("/images/presentation/start.PNG");
		sp3 = sp3.scaleTo(100, 100);
		ClickeableComponent start = new ClickeableComponent(gameModesXalign + 100, 600, sp3, 100, 100){
			public void onLeftClick(){
				this.getGame().setCurrentScene(new MainGameScene(numberOfTeams, getNumberOfWorms(), map));
			}
		};
		
		Sprite map1 = Sprite.fromImage("/map/terreno1.PNG");
		map1 = map1.scaleTo(150, 150);
		
		ClickeableComponent map1Comp = new ClickeableComponent(mapsXalign, mapsYalign, map1, 200, 200){
			public void onLeftClick(){
				map = 1;
			}
		};
		
		Sprite map2 = Sprite.fromImage("/map/terreno2.PNG");
		map2 = map2.scaleTo(150, 150);
		
		ClickeableComponent map2Comp = new ClickeableComponent(mapsXalign, mapsYalign + 160, map2, 200, 200){
			public void onLeftClick(){
				map = 2;
			}
		};
		
		
		Sprite map3 = Sprite.fromImage("/map/terreno3.PNG");
		map3 = map3.scaleTo(150, 150);
		
		ClickeableComponent map3Comp = new ClickeableComponent(mapsXalign, mapsYalign + 320, map3, 200, 200){
			public void onLeftClick(){
				map = 3;
			}
		};
		
		
		this.addComponent(map2Comp);
		this.addComponent(map3Comp);
		this.addComponent(map1Comp);
		this.addComponent(mode1v1);
		this.addComponent(mode2v2);
		this.addComponent(mode3v3);
		this.addComponent(mode1v1v1);
		this.addComponent(start);
	}

	private void addBackground() {
		GameComponent gc = new GameComponent();
		Sprite sp = Sprite.fromImage("/images/presentation/title-background2.jpg");
		sp = sp.scaleTo(800, 800);
		gc.setAppearance(sp);
		this.addComponent(gc);
		
	}

	private void addLabels() {

	}


	public int getNumberOfWorms() {
		return numberOfWorms;
	}

	public void setNumberOfWorms(int numberOfWorms) {
		this.numberOfWorms = numberOfWorms;
	}
}
